<template>
  <!-- 职工代表大会 -->
  <base-breadcrumb :title="$route.meta.title">
    <!-- 搜索 -->
    <searchData :searchData="searchArr" @search="search"></searchData>
    <!-- 表格 -->
    <a-card :bordered="false">
      <!-- <title-name :title="$route.meta.title"></title-name> -->
      <a-button v-btnPermission="'lu_003_add_01'" class="mb12" icon="plus" type="primary" @click="handleManage(2)"
        >新增</a-button
      >
      <!-- 表格 -->
      <list-table
        ref="table"
        tableLayout="fixed"
        size="default"
        rowKey="id"
        :columns="columns"
        :request="loadData"
        :alert="true"
        show-size-changer
        show-quick-jumper
        showPagination="auto"
      >
        <template slot="action" slot-scope="text, record">
          <MoreButton>
          <a v-btnPermission="'lu_003_loo_04'" @click="handleManage(0, record)">查看</a>
          <a-divider v-btnPermission="'lu_003_edi_02'" type="vertical"></a-divider>
          <a v-btnPermission="'lu_003_edi_02'" @click="handleManage(1, record)">编辑</a>
          <!-- 删除 -->
          <a-divider v-btnPermission="'lu_003_del_03'" type="vertical"></a-divider>
          <a v-btnPermission="'lu_003_del_03'" class="del_btn" @click="handleRemove(record.id)">删除</a>
          </MoreButton>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>
import { STable } from '@/components' // 表格
import { workersRepresentativeMeeting } from '@/api/union/workersCongress' // api
import Selector from '@/components/Select/Selector'
import BasePage from '@/views/basePage' // 基础配置
import SelectTreeUnion from '@/components/Select/SelectTreeUnion' // 工会

const searchArr = [
  // 搜索框
  {
    name: '会议名称',
    type: 'input',
    value: 'meetingName',
  },
  {
    name: '层级',
    type: Selector,
    valueKey: 'typeId',
    selectType: '1',
    urlType: 'union',
    attr: {
      limit: true,
    },
  },
  {
    name: '工会组织',
    type: SelectTreeUnion,
    valueKey: 'unionId',
  },
  {
    name: '时间',
    type: 'dateRange',
    value: 'time',
    attr: {
      rangeFormat: ['startTime', 'endTime'],
    },
  },
]
const columns = [
  // {
  //   title: '序号',
  //   width: 80,
  //   dataIndex: 'index',
  //   customRender() {
  //     return arguments[2] + 1
  //   },
  // },
  {
    title: '会议名称',
    ellipsis: true,
    dataIndex: 'meetingName',
  },
  {
    title: '层级',
    ellipsis: true,
    dataIndex: 'typeName',
  },
  {
    title: '工会组织',
    ellipsis: true,
    dataIndex: 'union',
  },
  {
    title: '参会人数',
    ellipsis: true,
    dataIndex: 'peopleNumber',
  },
  {
    title: '时间',
    ellipsis: true,
    dataIndex: 'meetingTime',
  },
  {
    title: '地点',
    dataIndex: 'place',
    ellipsis: true,
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: '180px',
    align: 'center',
    scopedSlots: { customRender: 'action' },
  },
]
export default {
    name:'a'+Date.now(),
  extends: new BasePage(),
  components: {
    STable,
  },
  data() {
    this.columns = columns
    this.searchArr = searchArr
    return {
      queryParam: {}, // 查询参数
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, { query: this.queryParam })
        return workersRepresentativeMeeting.getList(requestParameters).then((res) => {
          return res
        })
      }, // 加载数据方法 必须为 Promise 对象
      removeApi: workersRepresentativeMeeting, // 删除api
    }
  },
  methods: {
    // 搜索
    search(value) {
      value && (this.queryParam = value)
      this.$refs.table.refresh(true)
    },
    // 操作栏
    handleManage(type, record) {
      let query = {
        editModel: type,
      }
      if (record && record.id) {
        query.id = record.id
      }
      this.$router.push({
        name: '/union/democracy/workersCongressEdit',
        query,
      })
    },
  },
}
</script>
